﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
using System.Xml.Linq;

namespace Ocean.His.MedicalInsurance
{
    /// <summary>
    /// 基础入参
    /// </summary>
    [DataContract]
    public class SIBaseRequestModel
    {
        /// <summary>
        /// 交易编号
        /// </summary>
        [DataMember(Name = "infno")]
        public string Infno { get; set; }

        /// <summary>
        /// 发送方报文ID
        /// </summary>
        [DataMember(Name = "msgid")]
        public string Msgid { get; set; }

        /// <summary>
        /// 就医地医保区划
        /// </summary>
        [DataMember(Name = "mdtrtarea_admvs")]
        public string MdtrtareaAdmvs { get; set; }

        /// <summary>
        /// 参保地医保区划
        /// </summary>
        [DataMember(Name = "insuplc_admdvs")]
        public string InsuplcAdmdvs { get; set; }

        /// <summary>
        /// 接收方系统代码
        /// </summary>
        [DataMember(Name = "recer_sys_code")]
        public string RecerSysCode { get; set; }

        /// <summary>
        /// 设备编号
        /// </summary>
        [DataMember(Name = "dev_no")]
        public string DevNo { get; set; }

        /// <summary>
        /// 设备安全信息
        /// </summary>
        [DataMember(Name = "dev_safe_info")]
        public string DevSafeInfo { get; set; }

        /// <summary>
        /// 数字签名信息
        /// </summary>
        [DataMember(Name = "cainfo")]
        public string Cainfo { get; set; }

        /// <summary>
        /// 签名类型
        /// </summary>
        [DataMember(Name = "signtype")]
        public string Signtype { get; set; }

        /// <summary>
        /// 接口版本号
        /// </summary>
        [DataMember(Name = "infver")]
        public string Infver { get; set; }

        /// <summary>
        /// 经办人类别
        /// </summary>
        [DataMember(Name = "opter_type")]
        public string OpterType { get; set; }

        /// <summary>
        /// 经办人
        /// </summary>
        [DataMember(Name = "opter")]
        public string Opter { get; set; }

        /// <summary>
        /// 经办人姓名
        /// </summary>
        [DataMember(Name = "opter_name")]
        public string OpterName { get; set; }

        /// <summary>
        /// 交易时间
        /// </summary>
        [DataMember(Name = "inf_time")]
        public string InfTime { get; set; }

        /// <summary>
        /// 定点医药机构编号
        /// </summary>
        [DataMember(Name = "fixmedins_code")]
        public string FixmedinsCode { get; set; }

        /// <summary>
        /// 定点医药机构名称
        /// </summary>
        [DataMember(Name = "fixmedins_name")]
        public string FixmedinsName { get; set; }

        /// <summary>
        /// 交易签到流水号
        /// </summary>
        [DataMember(Name = "sign_no")]
        public string SignNo { get; set; }

        public SIBaseRequestModel(MedicalInsuranceOption medicalInsuranceOption)
        {
            var now = DateTime.Now;
            InfTime = now.ToString("yyyy-MM-dd HH:mm:ss");
            Msgid = medicalInsuranceOption.FixmedinsCode + now.ToString("yyyyMMddHHmmssfff");
            MdtrtareaAdmvs = medicalInsuranceOption.MdtrtareaAdmvs ?? string.Empty;
            RecerSysCode = medicalInsuranceOption.RecerSysCode ?? string.Empty;
            Infver = medicalInsuranceOption.Infver ?? string.Empty;
            //InsuplcAdmdvs = medicalInsuranceOption.InsuplcAdmdvs ?? string.Empty;
            FixmedinsCode = medicalInsuranceOption.FixmedinsCode ?? string.Empty;
            FixmedinsName = medicalInsuranceOption.FixmedinsName ?? string.Empty;
            DevNo = string.Empty;
            DevSafeInfo = string.Empty;
            Cainfo = medicalInsuranceOption.Cainfo ?? string.Empty;
            Signtype = string.Empty;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="msgid"></param>
        public void SetMsgId(string msgid)
        {
            Msgid = msgid;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="signNo"></param>
        public void SetSignNo(string signNo)
        {
            SignNo = signNo;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="opter"></param>
        /// <param name="opterName"></param>
        /// <param name="opterType"></param>
        public void SetOpter(string opter,string opterName, string opterType = "1")
        {
            OpterType = opterType; //经办人
            Opter = opter;
            OpterName = opterName;
        }

        /// <summary>
        /// 参保地医保区划
        /// 
        /// 如果交易输入中含有人员编号，此项必填，可通过【1101】人员信息获取交易取得
        /// </summary>
        public void SetInsuplcAdmdvs(string insuplcAdmdvs)
        {
            InsuplcAdmdvs = insuplcAdmdvs;
        }
    }
}
